package com.qf.service.impl;/*
@author fu
@date 2022/3/2622:17
*/

import com.qf.mapper.ShopMapper;
import com.qf.pojo.Shop;
import com.qf.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional//事务
public class ShopServiceImpl implements ShopService {

    //注入ShopMapper
    @Autowired
    private ShopMapper shopMapper;

    //获取所有的商品
    @Override
    public List<Shop> getAllShop() {

        List<Shop> list = shopMapper.findAll();
        if (list!=null){
            return list;
        }
        return null;
    }

    //通过商品id获取商品
    @Override
    public Shop getShop(Integer shopId) {

        Shop shop = shopMapper.seleceShopById(shopId);
        if (shop!=null){
            return shop;
        }
        return null;
    }

    //修改商品
    @Override
    public Integer updateShop(Shop shop) {

        Integer shop1 = shopMapper.updateShop(shop);
        if (shop1!=null){
            return shop1;
        }
        return null;
    }

    //删除商品
    @Override
    public Integer deteleShop(Integer shopId) {

        Integer shop = shopMapper.deteleShop(shopId);
        if (shop!=null){
            return shop;
        }
        return null;
    }

    //增加商品
    @Override
    public Integer addShop(Shop shop) {

        Integer addShop = shopMapper.addShop(shop);
        if (addShop!=null){
            return addShop;
        }
        return null;
    }
}
